#!/bin/sh

# Generate docset from reference docs.
#
# Docset is a format for packaging docs for offline consumption:
# https://kapeli.com/docsets
#
# External dependencies:
# 
# - python3

if test $# != 2; then
  echo "Usage: mkdocset.elv $website $docset"
  exit 1
fi

bindir=$(dirname "$0")
website=$1
docset=$2

mkdir -p $docset/Contents/Resources/Documents
cp $bindir/../favicons/favicon-16x16.png $docset/icon.png
cp $bindir/../favicons/favicon-32x32.png $docset/icon@2x.png
cp $bindir/docset-data/Info.plist $docset/Contents
cp $website/ref/*.html $docset/Contents/Resources/Documents
rm $docset/Contents/Resources/Documents/index.html
python3 $bindir/mkdsidx.py $website/ref $docset/Contents/Resources/docSet.dsidx
